﻿<UserControl x:Class="FormValidationExample.View.FormControl"
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
			 xmlns:i="clr-namespace:FormValidationExample.Infrastructure"
			 xmlns:View="clr-namespace:FormValidationExample.View"
             xmlns:ViewModel="clr-namespace:FormValidationExample.ViewModel"
             mc:Ignorable="d"
			 d:DataContext="{d:DesignInstance ViewModel:MainViewModel}">

	<UserControl.Resources>
		<Style x:Key="LabelTextBlockStyle"
			   TargetType="TextBlock">
			<Setter Property="FontWeight"
					Value="Bold" />
			<Setter Property="HorizontalAlignment"
					Value="Right" />
			<Setter Property="Margin"
					Value="0,0,10,0" />
			<Setter Property="VerticalAlignment"
					Value="Center" />
		</Style>
	</UserControl.Resources>
	<Grid>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="*" />
			<ColumnDefinition Width="Auto" />
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
		</Grid.RowDefinitions>

		<TextBlock Grid.Column="0"
				   Grid.Row="0"
				   Text="User Name"
				   Style="{StaticResource LabelTextBlockStyle}" />

		<TextBox Grid.Column="1"
				 Grid.Row="0"
				 Text="{Binding UserName, Mode=TwoWay, ValidatesOnNotifyDataErrors=True}" />
		
		<TextBlock Grid.Column="0"
				   Grid.Row="1"
				   Text="First Name"
				   Style="{StaticResource LabelTextBlockStyle}"
				   Margin="0,5,10,0"/>

		<TextBox Grid.Column="1"
				 Grid.Row="1"
				 Text="{Binding FirstName, Mode=TwoWay, ValidatesOnNotifyDataErrors=True}"
				 Margin="0,5,0,0"/>

		<TextBlock Grid.Column="0"
				   Grid.Row="2"
				   Text="Last Name"
				   Style="{StaticResource LabelTextBlockStyle}"
				   Margin="0,5,10,0" />

		<TextBox Grid.Column="1"
				 Grid.Row="2"
				 Text="{Binding LastName, Mode=TwoWay, ValidatesOnNotifyDataErrors=True}"
				 Margin="0,5,0,0" />

		<TextBlock Grid.Column="0"
				   Grid.Row="3"
				   Text="Email"
				   Style="{StaticResource LabelTextBlockStyle}"
				   Margin="0,5,10,0" />

		<TextBox Grid.Column="1"
				 Grid.Row="3"
				 Text="{Binding Email, Mode=TwoWay, ValidatesOnNotifyDataErrors=True}"
				 Margin="0,5,0,0" />

		<TextBlock Grid.Column="0"
				   Grid.Row="4"
				   Text="Password"
				   Style="{StaticResource LabelTextBlockStyle}"
				   Margin="0,10,10,0"
				   VerticalAlignment="Top" />

		<PasswordBox  Grid.Column="1"
					  Grid.Row="4"
					  Margin="0,5,0,0"
					  i:PasswordBoxAssistant.BindPassword="True"
					  i:PasswordBoxAssistant.BoundPassword="{Binding Password, Mode=TwoWay, ValidatesOnNotifyDataErrors=True}"
					  VerticalAlignment="Top" />

		<TextBlock Grid.Column="2"
				   Grid.Row="4"
				   Text="Should be at least 6 characters and contain both lowercase and uppcase letters as well as numbers."
				   FontSize="10"
				   TextWrapping="Wrap"
				   MaxWidth="100"
				   Margin="10,10,0,0" />

		<TextBlock Grid.Column="0"
				   Grid.Row="5"
				   Text="Confirm Password"
				   Style="{StaticResource LabelTextBlockStyle}"
				   Margin="0,5,10,0" />

		<PasswordBox Grid.Column="1"
					 Grid.Row="5"
					 i:PasswordBoxAssistant.BindPassword="True"
					 i:PasswordBoxAssistant.BoundPassword="{Binding PasswordConfirmation, Mode=TwoWay, ValidatesOnNotifyDataErrors=True}"
					 Margin="0,5,0,0" />

		<TextBlock Grid.Column="0"
				   Grid.Row="6"
				   Text="Interests"
				   Style="{StaticResource LabelTextBlockStyle}"
				   VerticalAlignment="Top"
				   Margin="0,8,10,0" />

		<View:InterestSelectorView Grid.Column="1"
								   Grid.Row="6"
								   DataContext="{Binding InterestSelectorViewModel}"
								   Margin="0,10,0,0" />

		<TextBlock Grid.Column="2"
				   Grid.Row="6"
				   Text="Please select at least 3 interests"
				   FontSize="10"
				   TextWrapping="Wrap"
				   MaxWidth="100"
				   Margin="10,10,0,0" />
	</Grid>
</UserControl>
